/*
2021-10-17
https://leetcode-cn.com/problems/check-if-numbers-are-ascending-in-a-sentence/
*/ 
class Solution {
public:
    bool areNumbersAscending(string s) {
        bool flag=true;

        int pre=-1;
        int n=s.size();
        int num=0;
        for(int i=0;i<n;i++)
        {
            if(s[i]>='0' && s[i]<='9')
            {
                while(i<n && s[i]>='0' && s[i]<='9')
                {
                    num=num*10+s[i]-'0';
                    i++;
                }
                if(num>pre) pre=num;
                else flag=false;
                num=0;
            }
        }
        return flag;
    }
};

